
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <unordered_map>
#include <vector>
#include <set>
#include <queue>

using namespace std;
using LL = long long;
using PII = pair<int, int>;

int n, m;
queue<int> q;
unordered_map<int, bool> mp;
int cnt;

int main(){
#ifdef LOCALFLAG
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif


    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> n >> m;
    for(int i = 1, x; i <= m; i ++){
        cin >> x;
        if(!mp[x]){
            if(q.size() == n) {
                mp[q.front()] = false;
                q.pop();
            }
            mp[x] = true;
            q.push(x);
            cnt ++;
        }
    }

    cout << cnt << '\n';

    return 0;
}